package cn.echoedu.control;

import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.echoedu.command.base.FailureParam;
import cn.echoedu.command.base.SuccessParam;
import cn.echoedu.constants.Role;
import cn.echoedu.entity.FeedBack;
import cn.echoedu.entity.Student;
import cn.echoedu.entity.Teacher;
import cn.echoedu.entity.User;
import cn.echoedu.entity.receivecommand.FeedBackReceive;
import cn.echoedu.entity.receivecommand.RegisterReceive;
import cn.echoedu.model.AddFeedBackModel;
import cn.echoedu.util.L;

public class FeedBackControl extends BaseControl{
	
private final String T="FeedBackControl";
    
	public void doFeedBack(HttpServletRequest request,
			HttpServletResponse response, FeedBackReceive feedBackReceive) throws SQLException {
		// TODO Auto-generated method stub
		final String M="doFeedBack**********>";
		L.p(T+M);
		
		FeedBack feedBack = new FeedBack();
		feedBack.setContactinfo(feedBackReceive.getContactinfo());
		feedBack.setContent(feedBackReceive.getContent());
		if(!addFeedBack().addFeedBack(feedBack)){
			sendFailure(response);
		}else{
			sendSuccess(response);
		}
	}
	
	private void sendFailure(HttpServletResponse response){
		FailureParam failureparam = new FailureParam();
		failureparam.setResponse(response);
		getResponseService().doFeedBackFailure(failureparam);
	}
	private void sendSuccess(HttpServletResponse response){
		SuccessParam successparam = new SuccessParam();
		successparam.setResponse(response);
		 getResponseService().doFeedBackSuccess(successparam);
	}
}
